//
//  WAOrderPopView.m
//  WalkiOS
//
//  Created by luqiuan on 2019/10/16.
//  Copyright © 2019 Chenmuzhou. All rights reserved.
//

#import "WAOrderPopView.h"

@interface WAOrderPopView ()
@property (nonatomic, strong) UIButton *bugButton;
@property (nonatomic, strong) UIButton *sellButton;
@end

@implementation WAOrderPopView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self initUI];
    }
    return self;
}

- (void)initUI{
    self.bugButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 90, 90)];
    [self.bugButton setTitle:@"买" forState:0];
    self.bugButton.titleLabel.font = WNCustomFont(20);
    [self.bugButton setTitleColor:[UIColor whiteColor] forState:0];
    [self.bugButton addTarget:self action:@selector(buyAction) forControlEvents:UIControlEventTouchDown];
    [self.contentView addSubview:self.bugButton];
    [self.bugButton setCenter:CGPointMake(WNScreenWidth/2, WNScreenHeight/2 - 90)];
    [self.bugButton addGradientLayerStartColor:0xEC9146 endColor:0xE4BB62 horizontal:YES];
    self.bugButton.layer.masksToBounds = YES;
    self.bugButton.layer.cornerRadius = self.bugButton.height/2;
    
    self.sellButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 90, 90)];
    [self.sellButton setTitle:@"卖" forState:0];
    self.sellButton.titleLabel.font = WNCustomFont(20);
    [self.sellButton setTitleColor:[UIColor whiteColor] forState:0];
    [self.sellButton addTarget:self action:@selector(sellAction) forControlEvents:UIControlEventTouchDown];
    [self.contentView addSubview:self.sellButton];
    [self.sellButton setCenter:CGPointMake(WNScreenWidth/2, WNScreenHeight/2 + 90)];
    [self.sellButton addGradientLayerStartColor:0x9EC9F7 endColor:0x6DA7E7 horizontal:NO];
    self.sellButton.layer.masksToBounds = YES;
    self.sellButton.layer.cornerRadius = self.sellButton.height/2;
}

- (void)buyAction{
    [self dismiss];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        if (self.orderClickBlock) {
            self.orderClickBlock(0);
        }
    });
}

- (void)sellAction{
    [self dismiss];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        if (self.orderClickBlock) {
            self.orderClickBlock(1);
        }
    });
}
@end
